import { queryDicNameList,updateDicName} from '@/services/bnsConfig/system';

export default {
  namespace: 'sysytem',

  state: {
    // 列表数据
    data: {},

    queryForm:{},
  },

  effects: {
    *queryList({ payload }, { call, put }) {
      const response = yield call(queryDicNameList, payload);
      yield put({
        type: 'save',
        payload: response,
      });
    },
    *update({ payload, callback }, { call, put }) {
      const response = yield call(updateDicName, payload);
      yield put({
        type: 'upData',
        payload: response,
      });
      if (callback) callback(response);
    },
  },

  reducers: {
    save(state, action) {
      if(action.payload.rescode == 200){
        return {
        ...state,
        data: action.payload.data,
        };
      }else{        
        return {
        ...state,
        data: [],
        };
      }
    }
  },
};
